/**
 * 用户相关API
 */
import request from '@/utils/request';
export const serviceHead = '/system'; // 项目前缀

// 获取路由
export function getRouters () {
  return request({
    url: `${serviceHead}/menu/getRouters`,
    method: 'get'
  });
};

/**
 * 修改登录密码
 * @returns {*}
 */
export function updatePassword (params) {
  return request({
    url: `${serviceHead}/user/profile/updatePwd`,
    method: 'put',
    data: params
  });
};

/**
* 查询用户列表
* @param params
* @returns {*}
*/
export function getUserList (params) {
  return request({
    url: `${serviceHead}/user/list`,
    method: 'get',
    params
  });
};

/**
* 查询用户详细
* @param params
* @returns {*}
*/
export function getUser (userId) {
  return request({
    url: `${serviceHead}/user/${userId}`,
    method: 'get'
  });
}

/**
* 获取用户详细信息
* @param params
* @returns {*}
*/
export function getInfo () {
  return request({
    url: `${serviceHead}/user/getInfo`,
    method: 'get'
  });
};

/**
* 新增用户
* @param params
* @returns {*}
*/
export function addUser (params) {
  return request({
    url: `${serviceHead}/user`,
    method: 'post',
    data: params
  });
};

/**
* 修改用户
* @param params
* @returns {*}
*/
export function updateUser (params) {
  return request({
    url: `${serviceHead}/user`,
    method: 'put',
    data: params
  });
};

/**
* 删除用户
* @param params
* @returns {*}
*/
export function delUser (userId) {
  return request({
    url: `${serviceHead}/user/${userId}`,
    method: 'delete'
  });
};

/**
 * 重置密码
 * @returns {*}
 */
export function resetUserPwd (params) {
  return request({
    url: `${serviceHead}/user/resetPwd`,
    method: 'put',
    data: params
  });
};

/**
 * 用户状态修改
 * @returns {*}
 */
export function changeUserStatus (params) {
  return request({
    url: `${serviceHead}/user/changeStatus`,
    method: 'put',
    data: params
  });
};

/**
 * 查询用户个人信息
 * @returns {*}
 */
export function getUserProfile () {
  return request({
    url: `${serviceHead}/user/profile`,
    method: 'get'
  });
};

/**
 * 修改用户个人信息
 * @returns {*}
 */
export function updateUserProfile (params) {
  return request({
    url: `${serviceHead}/user/profile`,
    method: 'put',
    data: params
  });
};

/**
 * 用户头像上传
 * @returns {*}
 */
export function uploadAvatar (params) {
  return request({
    url: `${serviceHead}/profile/avatar`,
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: params
  });
};

/**
 * 查询授权角色
 * @returns {*}
 */
export function getAuthRole (userId) {
  return request({
    url: `${serviceHead}/user/authRole/${userId}`,
    method: 'get'
  });
};

/**
 * 修改用户个人信息
 * @returns {*}
 */
export function updateAuthRole (params) {
  return request({
    url: `${serviceHead}/user/authRole`,
    method: 'put',
    data: params
  });
};

/**
 * 查询部门下拉树结构
 * @returns {*}
 */
export function deptTreeSelect () {
  return request({
    url: `${serviceHead}/user/deptTree`,
    method: 'get'
  });
};